alert('Scenesub.js loaded');

function Scenesub() {

};
var url;
var countPredictListMembers = 0;
var index = 1;
var index2 = 1;
var index3 = 1;

var focusIndex = 0;
var focusIndex1 = -1;
var codematches;
var nameteama;
var nameteamb;

Scenesub.prototype.initialize = function () {
	alert("Scenesub.initialize()");
	url = "http://quangdung.vv.si/main.php?";
	countPredictListMembers = 0;
	index = 1;
	index2 = 1;
	index3 = 1;
	focusIndex = 0;
	focusIndex1 = -1;
	// this function will be called only once when the scene manager show this scene first time
	// initialize the scene controls and styles, and initialize your variables here
	// scene HTML and CSS will be loaded before this function is called
	$('#Popup_invite').sfPopup({
        text : 'Bạn đã đặt cược trận đấu này. Bạn muốn thay đổi?',
        buttons : [ 'Ok', 'Cancel' ],
        defaultFocus: 1,callback : function(rlt) {
            if (rlt == 0) {
                //if invite accepted
                alert('accept');
                alert(url+'command=insert&FB_user='+id1+'&MS_Tran_dau='+code1+'&Lua_chon='+choose1+'&So_tien='+money1);
                $.getJSON(url+'command=insert&FB_user='+id1+'&MS_Tran_dau='+code1+'&Lua_chon='+choose1+'&So_tien='+money1, function(data) {
					var b = false;
					alert(data.error+".re.re");
					try {
						if(data.error.search('bạn')){
							$('#Popup_invite_ok').sfPopup('show');
							//$('#Popup_invite_ok').sfPopup('focus');
						}
					} catch (e) {
						$('#Popup_invite_success').sfPopup('show');
						//$('#Popup_invite_success').sfPopup('focus');
					}					
				});	
                sf.core.exit();
            }
            if(rlt==1){
            	 sf.core.exit();
					$('#Popup_invite').sfPopup('hide');
            }
        }
    });
	$("#Popup_invite").css({ top: '100px' });
	$("#Popup_invite").css({ left: '50px' });
	
	$('#Popup_invite_ok').sfPopup({
        text : 'Số tiền hiện tại của bạn không đủ để đặt cược',
        buttons : [ 'Ok' ],
        defaultFocus: 1,  callback : function(rlt) {
            if (rlt == 0) {
                //if invite accepted            
                alert('accept');
                sf.core.exit();
				$('#Popup_invite_ok').sfPopup('hide');
               // $.sf.returnFocus();
            }
        }
    });
	$("#Popup_invite_ok").css({ top: '100px' });
	$("#Popup_invite_ok").css({ left: '50px' });
	
	$('#Popup_invite_success').sfPopup({
        text : 'Đặt cược thành công. Vui lòng chờ kết quả',
        buttons : [ 'Ok' ],
        defaultFocus: 1, callback : function(rlt) {
            if (rlt == 0) {            	
                //if invite accepted
                alert('accept');    
                sf.core.exit();
				$('#Popup_invite_success').sfPopup('hide');
              //  $.sf.returnFocus();
            }
        }
    });
	$("#Popup_invite_success").css({ top: '100px' });
	$("#Popup_invite_success").css({ left: '50px' });
};
var teama;
Scenesub.prototype.handleShow = function (data) {
	alert("Scenesub.handleShow()");
	alert(data);
	var drawtext = "";	
	$('.namefootballmaches').html(data[0] +" vs " +data[1] +" - " +data[2]);
	alert(url+'command=getinfor&team='+data[0]);
	$.getJSON(url+'command=getinfor&team='+data[0], function(data) {
		
		$.each(data.result, function(index, value) {//time. chu nha, rate, doi khach
			$('.teama').html(value.Ten_CLB);
			$("#my_image_teama").attr("src",value.Logo);
			$('.teamawintotal').html(value.so_tran_thang);
			$('.teamadrawtotal').html(value.so_tran_hoa);
			$('.teamadefeattotal').html(value.so_tran_thua);
			$('.teamapredict').html(value.Ten_CLB+' thắng');
			teama = value.Ten_CLB;//+' hòa với ';
			nameteama = value.Ten_CLB;
		});		
	});	
	$.getJSON(url+'command=getinfor&team='+data[1], function(data) {
		
		$.each(data.result, function(index, value) {//time. chu nha, rate, doi khach
			$('.teamb').html(value.Ten_CLB);
			$("#my_image_teamb").attr("src",value.Logo);
			$('.teambwintotal').html(value.so_tran_thang);
			$('.teambdrawtotal').html(value.so_tran_hoa);
			$('.teambdefeattotal').html(value.so_tran_thua);
			$('.teambpredict').html(value.Ten_CLB+' thắng');
			drawtext += ' hòa với ' +value.Ten_CLB;
			$('.teamabpredict').html('2 đội hòa');
			nameteamb = value.Ten_CLB;
		});		
	});	
	$('#predictlistmembers').text('');
	codematches = data[3];
	alert(data[3]+'.adasd');
	var table = "<table id='idpredictlistmembers' class='scheduleTable'><tr><th>THỜI GIAN</th><th>THÀNH VIÊN</th><th>CHỌN</th><th>SỐ ĐIỂM</th></tr><tr><td colspan='4' class='jhead'>TOP 5 THÀNH VIÊN DỰ ĐOÁN</td></tr>";
	$.getJSON(url+'command=getlistpredict&codematches='+codematches, function(data) {
		
		$.each(data.result, function(index, value) {//time. chu nha, rate, doi khach
			table +='<tr id=\'idpredictlistmembers' +index +'\'>';
				table +='<td>'+value.Thoi_Gian_Dien_Ra+'</td>';
				table +='<td>'+value.FB_user+'</td>';
				table +='<td>'+value.Lua_chon+'</td>';		
				table +='<td>'+value.So_tien+'</td>';		
				
			table +='</tr>';
			objFootballMatch = {
					   Thoi_Gian_Dien_Ra : value.Thoi_Gian_Dien_Ra,
					   FB_user : value.FB_user,
					   Ban_Thang_1 : value.Ban_Thang_1,
					   Lua_chon : value.Lua_chon,
					   So_tien : value.So_tien,					  
			   };
			countPredictListMembers++;
			alert("alrty"+index+value.Thoi_Gian_Dien_Ra);
			//$(list).append('<li>' + value.description + ': ' + value.price + '</li>');
			   //alert(index + ":" + value.Thoi_Gian_Dien_Ra +':' +value.Doi_1 +':' +value.Ban_Thang_1);
			 
		});
		table +='</table>';
		alert("alert::::"+table);
		$(table).appendTo("#predictlistmembers");
	});	
	/*if(table.length==198){
		table += "<tr><td colspan='4'>Chưa có thành viên nào dự đoán</td></tr>";
		table +='</table>';
		alert("alert::::"+table.length);
		$(table).appendTo("#predictlistmembers");
	}*/
	
	/*var table2 = "<table id ='idtablehistorypredictlistmembers' class='scheduleTable' > <tr><th>THỜI GIAN</th><th>THÀNH VIÊN</th><th>SỐ ĐIỂM</th></tr><tr> <td colspan='3' class='jhead'>TOP 5 THÀNH VIÊN DỰ ĐOÁN</td></tr>";
	$.getJSON('http://thietkewebbatdongsan.com/tvapp/quanlysanbong/json/home.php', function(data) {
		
		$.each(data.ds_3_ngay_truoc, function(index, value) {//time. chu nha, rate, doi khach
			table2 +='<tr id=\'predict' +index +'\'>';
				table2 +='<td>'+value.Thoi_Gian_Dien_Ra+'</td>';
				table2 +='<td>'+value.Doi_1+'</td>';
				
				table2 +='<td>'+value.Doi_2+'</td>';				
			table2 +='</tr>';
			objFootballMatch = {
					   Thoi_Gian_Dien_Ra : value.Thoi_Gian_Dien_Ra,
					   Doi_1 : value.Doi_1,
					   Ban_Thang_1 : value.Ban_Thang_1,
					   The_do_1 : value.The_do_1,
					   Doi_2 : value.Doi_2,
					   Ban_Thang_2 : value.Ban_Thang_2,
					   The_do_2 : value.The_do_2,
					   Link_Report : value.Link_Report,
					   Ten_Tran_Dau : value.Ten_Tran_Dau,
					   published : value.published,
			   };
			listsPredict[index] = (objFootballMatch);
			countPredictTable++;
			//alert("....."+index+value.Thoi_Gian_Dien_Ra);
			//$(list).append('<li>' + value.description + ': ' + value.price + '</li>');
			   //alert(index + ":" + value.Thoi_Gian_Dien_Ra +':' +value.Doi_1 +':' +value.Ban_Thang_1);
			 
		});
		table2 +='</table>';
		//alert("alert2:"+table2);
		$(table2).appendTo("#historypredictlistmembers");
	});	*/
	$.getJSON(url+'command=countpredict&code='+codematches, function(data) {
		
		$.each(data.result, function(index, value) {//time. chu nha, rate, doi khach
			$('.countteambdrawwintotal').html('Số người tham gia: ' +value.count);//count(*)
			$('.countteambdrawtotal').html('Số người tham gia: ' +value.count);//count(*)
			$('.countteambwintotal').html('Số người tham gia: ' +value.count);//count(*)
			
		});
	});	
	$('.rateteambdrawwintotal').html('Tỷ lệ cược: ' +data[4]);//count(*)
	$('.rateteambdrawtotal').html('Tỷ lệ cược: ' +data[4]);//count(*)
	$('.rateteambwintotal').html('Tỷ lệ cược: ' +data[4]);//count(*)
	//alert("alert::::"+table.length);
	//window.location.href = "https://www.facebook.com/device";
	//onYouTubePlayerReady();
	// this function will be called when the scene manager show this scene
};

Scenesub.prototype.handleHide = function () {
	alert("Scenesub.handleHide()");
	// this function will be called when the scene manager hide this scene
};

Scenesub.prototype.handleFocus = function () {
	alert("Scenesub.handleFocus()");
	// this function will be called when the scene manager focus this scene
};

Scenesub.prototype.handleBlur = function () {
	alert("Scenesub.handleBlur()");
	// this function will be called when the scene manager move focus to another scene from this scene
};
$(function(i) {
    $("#my_select").val('\''+index+'\'');
});
/*var ytPlayer = null;
function onYouTubePlayerReady() {
  ytPlayer = document.getElementById('playerObject');
  if (ytPlayer) {
    ytPlayer.addEventListener('onStateChange','onChange');
    ytPlayer.addEventListener('onError', 'onError');
    ytPlayer.cueVideoById('i4iDWXstrWY'); //load video for play http://www.youtube.com/watch?v=i4iDWXstrWY
  } else {
    alert("error");
  }
}
function onChange(newState) {
  //Possible values are unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5)
  switch (newState) {
    case 5:
      ytPlayer.playVideo();
      break;
  }
function onError(errorCode) {
  alert(errorCode);
}*/
function createYoutube() {
	var html = "<object type='application/x-shockwave-flash' id='playerObject' style='width:507px; height:285.1px;'> "+
	            "<param name='movie' value='http://youtube.googleapis.com/apiplayer?version=3&enablejsapi=1'></param>"+
	            "<param name='allowScriptAccess' value='always'></param>"+
	            "<param name='wmode' value='transparent'></param> "+
	            "</object>";
	  var player = document.getElementById("playvideo");
	  widgetAPI.putInnerHTML(player,html);
}
function onYouTubePlayerReady()
{

    YouTubePlayer = document.getElementById('playerObject');
    YouTubePlayer.addEventListener('onStateChange','onPlayerStateChange');
    YouTubePlayer.addEventListener('onError', 'onPlayerError');


    refreshPlayer();
}
function autoPlayVideo(vcode, width, height){
	  "use strict";
	  $("#videoContainer").html('<iframe width="'+width+'" height="'+height+'" src="https://www.youtube.com/embed/'+vcode+'?autoplay=1&loop=1&rel=0&wmode=transparent" frameborder="0" allowfullscreen wmode="Opaque"></iframe>');
	}
function setSelectByValue(eID,val)
{ //Loop through sequentially//
  var ele=document.getElementById(eID);
  for(var ii=0; ii<ele.length; ii++){
	  alert("slesd");
    if(ele.options[ii].value==val) { //Found!
    	alert("slesd");
      ele.options[ii].selected=true;
      return true;
    }
  }
  return false;
}
var money;
Scenesub.prototype.handleKeyDown = function (keyCode) {
	alert("Scenesub.handleKeyDown(" + keyCode + ")");
	var positions = [0,00,600,850,1400];
	// TODO : write an key event handler when this scene get focued
	switch (keyCode) {
		case sf.key.LEFT:
			//jscrollPrev(positions);
			if(focusIndex1!=1&&focusIndex1!=3&&focusIndex1!=5){
				focusIndex--;
			}
			if(focusIndex==1){				
				/*index--;
				if(index==0){
					index = 7;
				}
				$('.id_100 option[value='+'\''+index+'\''+']').attr('selected','selected');
				*/if(focusIndex1==1){
					index--;
					if(index<=0){
						index = 7;
					}
					$('.id_100 option[value='+'\''+index+'\''+']').attr('selected','selected');					
				}
				if(focusIndex1==3){
					index2--;
					if(index2==0){
						index2 = 7;
					}
					$('.id_101 option[value='+'\''+index2+'\''+']').attr('selected','selected');					
				}
				if(focusIndex1==5){
					index3--;
					if(index3==0){
						index3 = 7;
					}
					$('.id_102 option[value='+'\''+index3+'\''+']').attr('selected','selected');					
				}
				if(focusIndex1!=1&&focusIndex1!=3&&focusIndex1!=5)
				jscrollTo(400,400);
				$('#posting').css('border-top', 'solid 0px red');
				$('#posting').css('border-left', 'solid 0px red');
				$('#posting').css('border-right', 'solid 0px red');
				$('#posting').css('border-bottom', 'solid 0px red');
				$('#iddivawin').css('border-top', 'solid 4px red');
				$('#iddivawin').css('border-left', 'solid 4px red');
				$('#iddivawin').css('border-right', 'solid 4px red');
				$('#iddivawin').css('border-bottom', 'solid 4px red');
			}
			if(focusIndex==2 && focusIndex1!=1&&focusIndex1!=3&&focusIndex1!=5){
				$('#idpredictlistmembers').css('border-bottom', 'solid 0px red');
				$('#idpredictlistmembers').css('border-top', 'solid 0px red');
				$('#idpredictlistmembers').css('border-left', 'solid 0px red');
				$('#idpredictlistmembers').css('border-right', 'solid 0px red');
				$('#posting').css('border-top', 'solid 4px red');
				$('#posting').css('border-left', 'solid 4px red');
				$('#posting').css('border-right', 'solid 4px red');
				$('#posting').css('border-bottom', 'solid 4px red');
				jscrollTo(700,700);
			}
			if(focusIndex==3 && focusIndex1!=1&&focusIndex1!=3&&focusIndex1!=5){
				$('#idpredictlistmembers').css('border-bottom', 'solid 4px red');
				$('#idpredictlistmembers').css('border-top', 'solid 4px red');
				$('#idpredictlistmembers').css('border-left', 'solid 4px red');
				$('#idpredictlistmembers').css('border-right', 'solid 4px red');
				$('#idtablehistorypredictlistmembers').css('border-bottom', 'solid 0px red');
				$('#idtablehistorypredictlistmembers').css('border-top', 'solid 0px red');
				$('#idtablehistorypredictlistmembers').css('border-left', 'solid 0px red');
				$('#idtablehistorypredictlistmembers').css('border-right', 'solid 0px red');
				
				jscrollTo(1200,1200);
			}
			
			
			if(focusIndex==-1){
				focusIndex = 4;
				$('#idtablehistorypredictlistmembers').css('border-bottom', 'solid 0px red');
				$('#idtablehistorypredictlistmembers').css('border-top', 'solid 0px red');
				$('#idtablehistorypredictlistmembers').css('border-left', 'solid 0px red');
				$('#idtablehistorypredictlistmembers').css('border-right', 'solid 0px red');
				
				jscrollTo(1800,1800);
			}
			if(focusIndex==4){
				
				$('#idtablehistorypredictlistmembers').css('border-bottom', 'solid 4px red');
				$('#idtablehistorypredictlistmembers').css('border-top', 'solid 4px red');
				$('#idtablehistorypredictlistmembers').css('border-left', 'solid 4px red');
				$('#idtablehistorypredictlistmembers').css('border-right', 'solid 4px red');
				
				jscrollTo(2000,2000);
						}
			if(focusIndex==0){
				focusIndex1 = -1;
				index = 1;
				index2 = 1;
				index3 = 1;
				$('#iddivawin').css('border-top', 'solid 0px red');
				$('#iddivawin').css('border-left', 'solid 0px red');
				$('#iddivawin').css('border-right', 'solid 0px red');
				$('#iddivawin').css('border-bottom', 'solid 0px red');
				$('#iddivadraw').css('border-top', 'solid 0px red');
				$('#iddivadraw').css('border-left', 'solid 0px red');
				$('#iddivadraw').css('border-right', 'solid 0px red');
				$('#iddivadraw').css('border-bottom', 'solid 0px red');
				$('#iddivb_win').css('border-top', 'solid 0px red');
				$('#iddivb_win').css('border-left', 'solid 0px red');
				$('#iddivb_win').css('border-right', 'solid 0px red');
				$('#iddivb_win').css('border-bottom', 'solid 0px red');
				$('.predicclassdivawin').css('border', 'solid 0px red');
				$('.predicclassdiva__draw').css('border', 'solid 0px red');
				$('.predicclassdivb___win').css('border', 'solid 0px red');
				jscrollTo(0,0);
			}
			alert(focusIndex+":::"+ focusIndex1+":::"+index+","+index2+","+index3);
			 
			break;
		case sf.key.RIGHT:
			  //autoPlayVideo('fl_1UIUIV3Q','450','283');
			if(focusIndex1!=1&&focusIndex1!=3&&focusIndex1!=5){
				focusIndex++;
			}
			if(focusIndex==1){
				if(focusIndex1==-1){
					focusIndex1++;
				}
				if(focusIndex1>=8){
					focusIndex1 = 0;
				}
				if(focusIndex1==0){
					$('#iddivawin').css('border-top', 'solid 4px red');
					$('#iddivawin').css('border-left', 'solid 4px red');
					$('#iddivawin').css('border-right', 'solid 4px red');
					$('#iddivawin').css('border-bottom', 'solid 4px red');
					jscrollTo(400,400);
				}
				
				if(focusIndex1==1){
					index++;
					$('.id_100 option[value='+'\''+index+'\''+']').attr('selected','selected');					
				}
				if(index==7){
					index = 0;
				}
				if(focusIndex1==3){
					index2++;
					$('.id_101 option[value='+'\''+index2+'\''+']').attr('selected','selected');					
				}
				if(index2==7){
					index2 = 0;
				}
				if(focusIndex1==5){
					index3++;
					$('.id_102 option[value='+'\''+index3+'\''+']').attr('selected','selected');					
				}
				if(index3==7){
					index3 = 0;
				}
			}
			if(focusIndex==2){
				focusIndex1 =0;
				index = 1;
				index2 = 1;
				index3 = 1;
				$('#iddivawin').css('border-top', 'solid 0px red');
				$('#iddivawin').css('border-left', 'solid 0px red');
				$('#iddivawin').css('border-right', 'solid 0px red');
				$('#iddivawin').css('border-bottom', 'solid 0px red');
				$('#iddivadraw').css('border-top', 'solid 0px red');
				$('#iddivadraw').css('border-left', 'solid 0px red');
				$('#iddivadraw').css('border-right', 'solid 0px red');
				$('#iddivadraw').css('border-bottom', 'solid 0px red');
				$('#iddivb_win').css('border-top', 'solid 0px red');
				$('#iddivb_win').css('border-left', 'solid 0px red');
				$('#iddivb_win').css('border-right', 'solid 0px red');
				$('#iddivb_win').css('border-bottom', 'solid 0px red');
				$('.predicclassdivawin').css('border', 'solid 0px red');
				$('.predicclassdiva__draw').css('border', 'solid 0px red');
				$('.predicclassdivb___win').css('border', 'solid 0px red');
				$('#posting').css('border-top', 'solid 4px red');
				$('#posting').css('border-left', 'solid 4px red');
				$('#posting').css('border-right', 'solid 4px red');
				$('#posting').css('border-bottom', 'solid 4px red');
				
				jscrollTo(700,700);
			}
			if(focusIndex==3){
				$('#posting').css('border-top', 'solid 0px red');
				$('#posting').css('border-left', 'solid 0px red');
				$('#posting').css('border-right', 'solid 0px red');
				$('#posting').css('border-bottom', 'solid 0px red');
				$('#idpredictlistmembers').css('border-bottom', 'solid 3px red');
				$('#idpredictlistmembers').css('border-top', 'solid 3px red');
				$('#idpredictlistmembers').css('border-left', 'solid 3px red');
				$('#idpredictlistmembers').css('border-right', 'solid 3px red');
				jscrollTo(1200,1200);
			}
			if(focusIndex==4){
				$('#idpredictlistmembers').css('border-bottom', 'solid 0px red');
				$('#idpredictlistmembers').css('border-top', 'solid 0px red');
				$('#idpredictlistmembers').css('border-left', 'solid 0px red');
				$('#idpredictlistmembers').css('border-right', 'solid 0px red');
				$('#idtablehistorypredictlistmembers').css('border-bottom', 'solid 4px red');
				$('#idtablehistorypredictlistmembers').css('border-top', 'solid 4px red');
				$('#idtablehistorypredictlistmembers').css('border-left', 'solid 4px red');
				$('#idtablehistorypredictlistmembers').css('border-right', 'solid 4px red');
				
				jscrollTo(1800,1800);
						}
			
			if(focusIndex==5){
				focusIndex = 0;
				$('#idtablehistorypredictlistmembers').css('border-bottom', 'solid 0px red');
				$('#idtablehistorypredictlistmembers').css('border-top', 'solid 0px red');
				$('#idtablehistorypredictlistmembers').css('border-left', 'solid 0px red');
				$('#idtablehistorypredictlistmembers').css('border-right', 'solid 0px red');
				
				jscrollTo(2200,2200);
			}

			if(focusIndex==0){
				jscrollTo(0,0);
			}
			alert(focusIndex+":::"+ focusIndex1+":::"+index+","+index2+","+index3);
			//$("#myselect").options['\''+index+'\''].selected=true;
			//setSelectByValue('my_select','\''+index+'\'');
			
			//jscrollNext(positions);
			//jscrollNext(positions);
			break;
		case sf.key.UP:
			if(focusIndex==1){
				focusIndex1--;
				if(focusIndex1<=0){
					focusIndex1=6;					
				}
				if(focusIndex1==1){
					alert("hre");
					$('.predicclassdiva__draw').css('border', 'solid 0px red');
					//borderhighlight('iddivawin','false');
					$('#iddivadraw').css('border-top', 'solid 0px red');
					$('#iddivadraw').css('border-left', 'solid 0px red');
					$('#iddivadraw').css('border-right', 'solid 0px red');
					$('#iddivadraw').css('border-bottom', 'solid 0px red');
					$('.predicclassdivawin').css('border', 'solid 0px red');
					$('#iddivawin').css('border-top', 'solid 4px red');
					$('#iddivawin').css('border-left', 'solid 4px red');
					$('#iddivawin').css('border-right', 'solid 4px red');
					$('#iddivawin').css('border-bottom', 'solid 4px red');
					borderhighlight('selectiddivawin','true');
				}
				if(focusIndex1==2){
					alert("hreasd");
					$('#selectiddivawindraw').css('border-top', 'solid 0px red');
					$('#selectiddivawindraw').css('border-left', 'solid 0px red');
					$('#selectiddivawindraw').css('border-right', 'solid 0px red');
					$('#selectiddivawindraw').css('border-bottom', 'solid 0px red');
					$('#iddivadraw').css('border-top', 'solid 0px red');
					$('#iddivadraw').css('border-left', 'solid 0px red');
					$('#iddivadraw').css('border-right', 'solid 0px red');
					$('#iddivadraw').css('border-bottom', 'solid 0px red');
					$('#iddivawin').css('border-top', 'solid 4px red');
					$('#iddivawin').css('border-left', 'solid 4px red');
					$('#iddivawin').css('border-right', 'solid 4px red');
					$('#iddivawin').css('border-bottom', 'solid 4px red');
					$('.predicclassdivawin').css('border', 'solid 4px red');
					//borderhighlight('selectiddivawin','false');
					//borderhighlightimg('predicclassdivawin','true');
					//$('#divpredicta').css('border-top', 'solid 4px red');
					//$('.predicclassdivawin').css('border', 'solid 4px red');
					//$('.predicclassdivawin').attr('src', 'images/720/predictpress.png');
				}
				if(focusIndex1==3){
					alert("hre3");
					$('.predicclassdiva__draw').css('border', 'solid 0px red');
					//borderhighlight('iddivawin','false');
					
					$('#selectiddivawindraw').css('border-top', 'solid 4px red');
					$('#selectiddivawindraw').css('border-left', 'solid 4px red');
					$('#selectiddivawindraw').css('border-right', 'solid 4px red');
					$('#selectiddivawindraw').css('border-bottom', 'solid 4px red');
					
					//borderhighlight('selectiddivawindraw','true');
					//borderhighlight('selectiddivadraw','true');
				}
				if(focusIndex1==4){
					alert("hre");
					$('#iddivb_win').css('border-top', 'solid 0px red');
					$('#iddivb_win').css('border-left', 'solid 0px red');
					$('#iddivb_win').css('border-right', 'solid 0px red');
					$('#iddivb_win').css('border-bottom', 'solid 0px red');
					$('#selectiddivbwin__').css('border-top', 'solid 0px red');
					$('#selectiddivbwin__').css('border-left', 'solid 0px red');
					$('#selectiddivbwin__').css('border-right', 'solid 0px red');
					$('#selectiddivbwin__').css('border-bottom', 'solid 0px red');
					$('.predicclassdiva__draw').css('border', 'solid 4px red');
					$('#iddivadraw').css('border-top', 'solid 4px red');
					$('#iddivadraw').css('border-left', 'solid 4px red');
					$('#iddivadraw').css('border-right', 'solid 4px red');
					$('#iddivadraw').css('border-bottom', 'solid 4px red');
					//borderhighlight('selectiddivawin','true');
				}
				if(focusIndex1==5){
					alert("hre");
					$('.predicclassdivb___win').css('border', 'solid 0px red');
					
					$('#selectiddivbwin__').css('border-top', 'solid 4px red');
					$('#selectiddivbwin__').css('border-left', 'solid 4px red');
					$('#selectiddivbwin__').css('border-right', 'solid 4px red');
					$('#selectiddivbwin__').css('border-bottom', 'solid 4px red');
				}
				if(focusIndex1==6){
					alert("hre");
					$('.predicclassdivawin').css('border', 'solid 0px red');
					//borderhighlight('iddivawin','false');
					$('#iddivawin').css('border-top', 'solid 0px red');
					$('#iddivawin').css('border-left', 'solid 0px red');
					$('#iddivawin').css('border-right', 'solid 0px red');
					$('#iddivawin').css('border-bottom', 'solid 0px red');
					borderhighlight('selectiddivawin','false');
					$('#iddivb_win').css('border-top', 'solid 4px red');
					$('#iddivb_win').css('border-left', 'solid 4px red');
					$('#iddivb_win').css('border-right', 'solid 4px red');
					$('#iddivb_win').css('border-bottom', 'solid 4px red');
					$('.predicclassdivb___win').css('border', 'solid 4px red');
					//borderhighlight('selectiddivawin','true');
				}
			}
			jscrollDown(0);
			alert(focusIndex+":::"+ focusIndex1+":::"+index);
			break;
		case sf.key.DOWN:
			//jscrollDown(200);
			//alert(focusIndex+":"+focusIndex1);
			if(focusIndex==1){
				focusIndex1++;
				if(focusIndex1==7){
					focusIndex1=1;					
				}
				if(focusIndex1==1){
					alert("hre");
					$('.predicclassdivb___win').css('border', 'solid 0px red');
					$('#iddivb_win').css('border-top', 'solid 0px red');
					$('#iddivb_win').css('border-left', 'solid 0px red');
					$('#iddivb_win').css('border-right', 'solid 0px red');
					$('#iddivb_win').css('border-bottom', 'solid 0px red');
					$('#iddivawin').css('border-top', 'solid 4px red');
					$('#iddivawin').css('border-left', 'solid 4px red');
					$('#iddivawin').css('border-right', 'solid 4px red');
					$('#iddivawin').css('border-bottom', 'solid 4px red');
					borderhighlight('selectiddivawin','true');
				}
				if(focusIndex1==2){
					alert("hreasd");
					borderhighlight('selectiddivawin','false');
					//borderhighlightimg('predicclassdivawin','true');
					//$('#divpredicta').css('border-top', 'solid 4px red');
					$('.predicclassdivawin').css('border', 'solid 4px red');
					//$('.predicclassdivawin').attr('src', 'images/720/predictpress.png');
				}
				if(focusIndex1==3){
					alert("hre3");
					$('.predicclassdivawin').css('border', 'solid 0px red');
					//borderhighlight('iddivawin','false');
					$('#iddivawin').css('border-top', 'solid 0px red');
					$('#iddivawin').css('border-left', 'solid 0px red');
					$('#iddivawin').css('border-right', 'solid 0px red');
					$('#iddivawin').css('border-bottom', 'solid 0px red');
					
					$('#iddivadraw').css('border-top', 'solid 4px red');
					$('#iddivadraw').css('border-left', 'solid 4px red');
					$('#iddivadraw').css('border-right', 'solid 4px red');
					$('#iddivadraw').css('border-bottom', 'solid 4px red');
					
					$('#selectiddivawindraw').css('border-top', 'solid 4px red');
					$('#selectiddivawindraw').css('border-left', 'solid 4px red');
					$('#selectiddivawindraw').css('border-right', 'solid 4px red');
					$('#selectiddivawindraw').css('border-bottom', 'solid 4px red');
					
					//borderhighlight('selectiddivawindraw','true');
					//borderhighlight('selectiddivadraw','true');
				}
				if(focusIndex1==4){
					alert("hre");
					$('#selectiddivawindraw').css('border-top', 'solid 0px red');
					$('#selectiddivawindraw').css('border-left', 'solid 0px red');
					$('#selectiddivawindraw').css('border-right', 'solid 0px red');
					$('#selectiddivawindraw').css('border-bottom', 'solid 0px red');
					
					$('.predicclassdiva__draw').css('border', 'solid 4px red');
					//borderhighlight('selectiddivawin','true');
				}
				if(focusIndex1==5){
					alert("hre");
					$('.predicclassdiva__draw').css('border', 'solid 0px red');
					//borderhighlight('iddivawin','false');
					$('#iddivadraw').css('border-top', 'solid 0px red');
					$('#iddivadraw').css('border-left', 'solid 0px red');
					$('#iddivadraw').css('border-right', 'solid 0px red');
					$('#iddivadraw').css('border-bottom', 'solid 0px red');
					
					$('#iddivb_win').css('border-top', 'solid 4px red');
					$('#iddivb_win').css('border-left', 'solid 4px red');
					$('#iddivb_win').css('border-right', 'solid 4px red');
					$('#iddivb_win').css('border-bottom', 'solid 4px red');
					
					$('#selectiddivbwin__').css('border-top', 'solid 4px red');
					$('#selectiddivbwin__').css('border-left', 'solid 4px red');
					$('#selectiddivbwin__').css('border-right', 'solid 4px red');
					$('#selectiddivbwin__').css('border-bottom', 'solid 4px red');
				}
				if(focusIndex1==6){
					alert("hre");
					$('#selectiddivbwin__').css('border-top', 'solid 0px red');
					$('#selectiddivbwin__').css('border-left', 'solid 0px red');
					$('#selectiddivbwin__').css('border-right', 'solid 0px red');
					$('#selectiddivbwin__').css('border-bottom', 'solid 0px red');
					
					$('.predicclassdivb___win').css('border', 'solid 4px red');
					//borderhighlight('selectiddivawin','true');
				}
			}
			alert(focusIndex+":::"+ focusIndex1+":::"+index);
			break;
		case sf.key.ENTER:
			alert(focusIndex+":::"+ focusIndex1+":::"+index);
			if(focusIndex==1){
				if(focusIndex1==2){
					money = $("#selectiddivawin option:selected").text();
					money = money.replace('.','');
					var id = 'namnhi.le';
					var code = codematches;
					alert(url+'command=getpredicted&FB_user='+id+'&MS_Tran_dau='+code+".."+money);
					$.getJSON(url+'command=getpredicted&FB_user='+id+'&MS_Tran_dau='+code, function(data) {
						var b = false;
						try {
							money = $("#selectiddivawin option:selected").text();
							money = money.replace('.','');
							alert(data.error+"../"+money);
							if(data.error.toLowerCase()=='error'){
						//		alert('a');
						//		alert('a'+url);
								//alert(data.error+".re."+url+'command=getpredicted&FB_user='+id+'&MS_Tran_dau='+code);
						//		alert(""+url+'command=insert&FB_user='+id+'&MS_Tran_dau='+code+'&Lua_chon='+nameteama+'&So_tien='+money);
								$.getJSON(url+'command=insert&FB_user='+id+'&MS_Tran_dau='+code+'&Lua_chon='+nameteama+'&So_tien='+money, function(data) {
										var b = false;
										alert(data.error+".re.re");
										try {
											if(data.error.search('bạn')){
												$('#Popup_invite_ok').sfPopup({
													text:''+data.error,
													buttons:['OK'],
													timeout:50000,
													callback:function(){

											       

											                sf.scene.focus('sub');}															

												}).sfPopup('show');
												$("#Popup_invite_ok").css({ top: '100px' });
												$("#Popup_invite_ok").css({ left: '50px' });
												//$('#Popup_invite_ok').sfPopup('show');
												//$('#Popup_invite_ok').sfPopup('focus');
											}
										} catch (e) {
											//$('#Popup_invite_success').sfPopup('show');
											$('#Popup_invite_ok').sfPopup({
												text:'Đặt cược thành công. Vui lòng chờ kết quả',
												buttons:['OK'],
												timeout:50000,
												callback:function(){

										       

										                sf.scene.focus('sub');}


											}).sfPopup('show');
											$("#Popup_invite_ok").css({ top: '100px' });
											$("#Popup_invite_ok").css({ left: '50px' });
											//$('#Popup_invite_success').sfPopup('focus');
										}										
									});	
							}
							else{
								alert(data.error+"............../"+money);
								/*id1 = id;
								code1 = code;
								choose1 = choose;
								money1 = money;*/
								$('#Popup_invite_ok').sfPopup({
							        text : 'Bạn đã đặt cược trận đấu này. Bạn muốn thay đổi?',
							        buttons : [ 'Ok', 'Cancel' ],
							        timeout:50000,
							        callback : function(rlt) {
							            if (rlt == 0) {
							                //if invite accepted
							                alert('accept.'+money+"................................");
							                alert(url+'command=insert&FB_user='+id+'&MS_Tran_dau='+code+'&Lua_chon='+nameteama+'&So_tien='+money);
							                $.getJSON(url+'command=insert&FB_user='+id+'&MS_Tran_dau='+code+'&Lua_chon='+nameteama+'&So_tien='+money, function(data) {
												var b = false;
												alert(data.error+".re.re");
												try {
													if(data.error.search('bạn')){
														$('#Popup_invite').sfPopup({
															text:''+data.error,
															buttons:['OK'],
															timeout:50000,
															callback:function(){

													       

													                sf.scene.focus('sub');}


														}).sfPopup('show');
														$("#Popup_invite").css({ top: '100px' });
														$("#Popup_invite").css({ left: '50px' });
														//$('#Popup_invite_ok').sfPopup('show');
														//$('#Popup_invite_ok').sfPopup('focus');
													}
												} catch (e) {
													$('#Popup_invite').sfPopup({
														text:'Đặt cược thành công. Vui lòng chờ kết quả',
														buttons:['OK'],
														timeout:50000,
														callback:function(){

												       

												                sf.scene.focus('sub');}


													}).sfPopup('show');
													$("#Popup_invite").css({ top: '100px' });
													$("#Popup_invite").css({ left: '50px' });
													//$('#Popup_invite_success').sfPopup('show');
													//$('#Popup_invite_success').sfPopup('focus');
												}					
											});	
							               // sf.core.exit();
							            }
							            if(rlt==1){
							            	 sf.scene.focus('sub');
							            }
							        }
							    }).sfPopup('show');;
								$("#Popup_invite_ok").css({ top: '100px' });
								$("#Popup_invite_ok").css({ left: '50px' });
								//$('#Popup_invite').sfPopup('focus');
							}
						} catch (e) {							
						}
						
						
					});						
				}
				if(focusIndex1==4){
					money = $("#selectiddivawindraw option:selected").text();
					money = money.replace('.','');
					var id = 'namnhi.le';
					var code = codematches;
					alert(url+'command=getpredicted&FB_user='+id+'&MS_Tran_dau='+code+".."+money);
					$.getJSON(url+'command=getpredicted&FB_user='+id+'&MS_Tran_dau='+code, function(data) {
						var b = false;
						try {
							money = $("#selectiddivawindraw option:selected").text();
							money = money.replace('.','');
							alert(data.error+"../"+money);
							if(data.error.toLowerCase()=='error'){
						//		alert('a');
						//		alert('a'+url);
								//alert(data.error+".re."+url+'command=getpredicted&FB_user='+id+'&MS_Tran_dau='+code);
						//		alert(""+url+'command=insert&FB_user='+id+'&MS_Tran_dau='+code+'&Lua_chon='+nameteama+'&So_tien='+money);
								$.getJSON(url+'command=insert&FB_user='+id+'&MS_Tran_dau='+code+'&Lua_chon=draw&So_tien='+money, function(data) {
										var b = false;
										alert(data.error+".re.re");
										try {
											if(data.error.search('bạn')){
												$('#Popup_invite_ok').sfPopup({
													text:''+data.error,
													buttons:['OK'],
													timeout:50000,
													callback:function(){

											       

											                sf.scene.focus('sub');}															

												}).sfPopup('show');
												$("#Popup_invite_ok").css({ top: '100px' });
												$("#Popup_invite_ok").css({ left: '50px' });
												//$('#Popup_invite_ok').sfPopup('show');
												//$('#Popup_invite_ok').sfPopup('focus');
											}
										} catch (e) {
											//$('#Popup_invite_success').sfPopup('show');
											$('#Popup_invite_ok').sfPopup({
												text:'Đặt cược thành công. Vui lòng chờ kết quả',
												buttons:['OK'],
												timeout:50000,
												callback:function(){

										       

										                sf.scene.focus('sub');}


											}).sfPopup('show');
											$("#Popup_invite_ok").css({ top: '100px' });
											$("#Popup_invite_ok").css({ left: '50px' });
											//$('#Popup_invite_success').sfPopup('focus');
										}										
									});	
							}
							else{
								alert(data.error+"............../"+money);
								/*id1 = id;
								code1 = code;
								choose1 = choose;
								money1 = money;*/
								$('#Popup_invite_ok').sfPopup({
							        text : 'Bạn đã đặt cược trận đấu này. Bạn muốn thay đổi?',
							        buttons : [ 'Ok', 'Cancel' ],
							        timeout:50000,
							        callback : function(rlt) {
							            if (rlt == 0) {
							                //if invite accepted
							                alert('accept.'+money+"................................");
							                alert(url+'command=insert&FB_user='+id+'&MS_Tran_dau='+code+'&Lua_chon=draw&So_tien='+money);
							                $.getJSON(url+'command=insert&FB_user='+id+'&MS_Tran_dau='+code+'&Lua_chon=draw&So_tien='+money, function(data) {
												var b = false;
												alert(data.error+".re.re");
												try {
													if(data.error.search('bạn')){
														$('#Popup_invite').sfPopup({
															text:''+data.error,
															buttons:['OK'],
															timeout:50000,
															callback:function(){

													       

													                sf.scene.focus('sub');}


														}).sfPopup('show');
														$("#Popup_invite").css({ top: '100px' });
														$("#Popup_invite").css({ left: '50px' });
														//$('#Popup_invite_ok').sfPopup('show');
														//$('#Popup_invite_ok').sfPopup('focus');
													}
												} catch (e) {
													$('#Popup_invite').sfPopup({
														text:'Đặt cược thành công. Vui lòng chờ kết quả',
														buttons:['OK'],
														timeout:50000,
														callback:function(){

												       

												                sf.scene.focus('sub');}


													}).sfPopup('show');
													$("#Popup_invite").css({ top: '100px' });
													$("#Popup_invite").css({ left: '50px' });
													//$('#Popup_invite_success').sfPopup('show');
													//$('#Popup_invite_success').sfPopup('focus');
												}					
											});	
							               // sf.core.exit();
							            }
							            if(rlt==1){
							            	 sf.scene.focus('sub');
							            }
							        }
							    }).sfPopup('show');;
								$("#Popup_invite_ok").css({ top: '100px' });
								$("#Popup_invite_ok").css({ left: '50px' });
								//$('#Popup_invite').sfPopup('focus');
							}
						} catch (e) {							
						}
						
						
					});	
					//alert(money);sentpredicttoserver('namnhi.le', codematches, 'draw', money);
				}
				if(focusIndex1=6){
					money = $("#selectiddivbwin__ option:selected").text();
					money = money.replace('.','');
					var id = 'namnhi.le';
					var code = codematches;
					alert(url+'command=getpredicted&FB_user='+id+'&MS_Tran_dau='+code+".."+money);
					$.getJSON(url+'command=getpredicted&FB_user='+id+'&MS_Tran_dau='+code, function(data) {
						var b = false;
						try {
							money = $("#selectiddivbwin__ option:selected").text();
							money = money.replace('.','');
							alert(data.error+"../"+money);
							if(data.error.toLowerCase()=='error'){
						//		alert('a');
						//		alert('a'+url);
								//alert(data.error+".re."+url+'command=getpredicted&FB_user='+id+'&MS_Tran_dau='+code);
						//		alert(""+url+'command=insert&FB_user='+id+'&MS_Tran_dau='+code+'&Lua_chon='+nameteama+'&So_tien='+money);
								$.getJSON(url+'command=insert&FB_user='+id+'&MS_Tran_dau='+code+'&Lua_chon='+nameteamb+'&So_tien='+money, function(data) {
										var b = false;
										alert(data.error+".re.re");
										try {
											if(data.error.search('bạn')){
												$('#Popup_invite_ok').sfPopup({
													text:''+data.error,
													buttons:['OK'],
													timeout:50000,
													callback:function(){

											       

											                sf.scene.focus('sub');}															

												}).sfPopup('show');
												$("#Popup_invite_ok").css({ top: '100px' });
												$("#Popup_invite_ok").css({ left: '50px' });
												//$('#Popup_invite_ok').sfPopup('show');
												//$('#Popup_invite_ok').sfPopup('focus');
											}
										} catch (e) {
											//$('#Popup_invite_success').sfPopup('show');
											$('#Popup_invite_ok').sfPopup({
												text:'Đặt cược thành công. Vui lòng chờ kết quả',
												buttons:['OK'],
												timeout:50000,
												callback:function(){

										       

										                sf.scene.focus('sub');}


											}).sfPopup('show');
											$("#Popup_invite_ok").css({ top: '100px' });
											$("#Popup_invite_ok").css({ left: '50px' });
											//$('#Popup_invite_success').sfPopup('focus');
										}										
									});	
							}
							else{
								alert(data.error+"............../"+money);
								/*id1 = id;
								code1 = code;
								choose1 = choose;
								money1 = money;*/
								$('#Popup_invite_ok').sfPopup({
							        text : 'Bạn đã đặt cược trận đấu này. Bạn muốn thay đổi?',
							        buttons : [ 'Ok', 'Cancel' ],
							        timeout:50000,
							        callback : function(rlt) {
							            if (rlt == 0) {
							                //if invite accepted
							                alert('accept.'+money+"................................");
							                alert(url+'command=insert&FB_user='+id+'&MS_Tran_dau='+code+'&Lua_chon=draw&So_tien='+money);
							                $.getJSON(url+'command=insert&FB_user='+id+'&MS_Tran_dau='+code+'&Lua_chon='+nameteamb+'&So_tien='+money, function(data) {
												var b = false;
												alert(data.error+".re.re");
												try {
													if(data.error.search('bạn')){
														$('#Popup_invite').sfPopup({
															text:''+data.error,
															buttons:['OK'],
															timeout:50000,
															callback:function(){

													       

													                sf.scene.focus('sub');}


														}).sfPopup('show');
														$("#Popup_invite").css({ top: '100px' });
														$("#Popup_invite").css({ left: '50px' });
														//$('#Popup_invite_ok').sfPopup('show');
														//$('#Popup_invite_ok').sfPopup('focus');
													}
												} catch (e) {
													$('#Popup_invite').sfPopup({
														text:'Đặt cược thành công. Vui lòng chờ kết quả',
														buttons:['OK'],
														timeout:50000,
														callback:function(){

												       

												                sf.scene.focus('sub');}


													}).sfPopup('show');
													$("#Popup_invite").css({ top: '100px' });
													$("#Popup_invite").css({ left: '50px' });
													//$('#Popup_invite_success').sfPopup('show');
													//$('#Popup_invite_success').sfPopup('focus');
												}					
											});	
							               // sf.core.exit();
							            }
							            if(rlt==1){
							            	 sf.scene.focus('sub');
							            }
							        }
							    }).sfPopup('show');;
								$("#Popup_invite_ok").css({ top: '100px' });
								$("#Popup_invite_ok").css({ left: '50px' });
								//$('#Popup_invite').sfPopup('focus');
							}
						} catch (e) {							
						}
						
						
					});	
					//sentpredicttoserver('namnhi.le', codematches, nameteamb, money);
				}
				
			}
			break;
		case sf.key.RETURN:
			alert("return");
			sf.scene.hide('sub');
			sf.scene.show('home',"return");
			sf.scene.focus('home');
			break;
		default:
			alert("handle default key event, key code(" + keyCode + ")");
			break;
	}
};
var id;
/*function sentpredicttoserver(id, code, choose, money) {
	id = 'namnhi.le';
	$.getJSON(url+'command=getpredicted&FB_user='+id+'&MS_Tran_dau='+code, function(data) {
		var b = false;
		try {
			alert(data.error+".re."+url+'command=getpredicted&FB_user='+id+'&MS_Tran_dau='+code);
			if(data.error=='error'){
				alert(url+'command=insert&FB_user='+id+'&MS_Tran_dau='+code+'&Lua_chon='+choose+'&So_tien='+money);
				$.getJSON(url+'command=insert&FB_user='+id+'&MS_Tran_dau='+code+'&Lua_chon='+choose+'&So_tien='+money, function(data) {
						var b = false;
						alert(data.error+".re.re");
						try {
							if(data.error.search('bạn')){
								$('#Popup_invite').sfPopup({
									text:''+data.error,
									buttons:['OK'],
									timeout:50000,
									callback:function(){

							       

							                sf.scene.focus('sub');}


								}).sfPopup('show');
								$("#Popup_invite").css({ top: '100px' });
								$("#Popup_invite").css({ left: '50px' });
								//$('#Popup_invite_ok').sfPopup('show');
								//$('#Popup_invite_ok').sfPopup('focus');
							}
						} catch (e) {
							//$('#Popup_invite_success').sfPopup('show');
							$('#Popup_invite').sfPopup({
								text:'Đặt cược thành công. Vui lòng chờ kết quả',
								buttons:['OK'],
								timeout:50000,
								callback:function(){

						       

						                sf.scene.focus('sub');}


							}).sfPopup('show');
							$("#Popup_invite").css({ top: '100px' });
							$("#Popup_invite").css({ left: '50px' });
							//$('#Popup_invite_success').sfPopup('focus');
						}
						
						try {
							$.each(data.result, function(index, value) {//time. chu nha, rate, doi khach			
								var resopne = value;
								if(resopne=="success"){
									b = true;
								}
								alert(value+'...'); 
							});
						} catch (e) {
							$.each(data, function(index, value) {//time. chu nha, rate, doi khach			
								var resopne = value;
								if(resopne=="success"){
									b = true;
								}
								alert(value+'...s'); 
							});
						}
						
						
					});	
			}
			else{
				id1 = id;
				code1 = code;
				choose1 = choose;
				money1 = money;
				$('#Popup_invite').sfPopup({
			        text : 'Bạn đã đặt cược trận đấu này. Bạn muốn thay đổi?',
			        buttons : [ 'Ok', 'Cancel' ],
			        defaultFocus: 1,callback : function(rlt) {
			            if (rlt == 0) {
			                //if invite accepted
			                alert('accept');
			                alert(url+'command=insert&FB_user='+id1+'&MS_Tran_dau='+code1+'&Lua_chon='+choose1+'&So_tien='+money1);
			                $.getJSON(url+'command=insert&FB_user='+id1+'&MS_Tran_dau='+code1+'&Lua_chon='+choose1+'&So_tien='+money1, function(data) {
								var b = false;
								alert(data.error+".re.re");
								try {
									if(data.error.search('bạn')){
										$('#Popup_invite').sfPopup({
											text:''+data.error,
											buttons:['OK'],
											timeout:10000,
											callback:function(){

									       

									                sf.scene.focus('sub');}


										}).sfPopup('show');
										$("#Popup_invite").css({ top: '100px' });
										$("#Popup_invite").css({ left: '50px' });
										$('#Popup_invite_ok').sfPopup('show');
										//$('#Popup_invite_ok').sfPopup('focus');
									}
								} catch (e) {
									$('#Popup_invite').sfPopup({
										text:'Đặt cược thành công. Vui lòng chờ kết quả',
										buttons:['OK'],
										timeout:10000,
										callback:function(){

								       

								                sf.scene.focus('sub');}


									}).sfPopup('show');
									$("#Popup_invite").css({ top: '100px' });
									$("#Popup_invite").css({ left: '50px' });
									$('#Popup_invite_success').sfPopup('show');
									//$('#Popup_invite_success').sfPopup('focus');
								}					
							});	
			               // sf.core.exit();
			            }
			            if(rlt==1){
			            	 sf.scene.focus('sub');
			            }
			        }
			    });
				//$("#Popup_invite").css({ top: '100px' });
				//$("#Popup_invite").css({ left: '50px' });
				//$('#Popup_invite').sfPopup('focus');
			}
		} catch (e) {
			$.each(data, function(index, value) {//time. chu nha, rate, doi khach			
				var resopne = value;
				if(resopne=="success"){
					b = true;
				}
				alert(value+'.../'); 
			});
		}
		
		
	});	
	
}*/
function sentpredictwin() {
	alert('predict');
		var money = $("#selectiddivawin option:selected").text();
			money = money.replace('.','');
			sentpredicttoserver('namnhi.le', codematches, nameteama, money);
			alert(money+"asd..");
		
		
	
}
function sentpredictdraw() {
	alert('predict');
	var money = $("#selectiddivawindraw option:selected").text();
	money = money.replace('.','');
	alert(money);sentpredicttoserver('namnhi.le', codematches, 'draw', money);
}
function sentpredictfail() {
	alert('predict');
	var money = $("#selectiddivbwin__ option:selected").text();
	money = money.replace('.','');
	alert(money+":"+nameteamb);
	sentpredicttoserver('namnhi.le', codematches, nameteamb, money);
}
function borderhighlight(id,flag) {
	if(flag=="true"){
		$('#selectiddivawin').css('border-top', 'solid 4px red');
		$('#selectiddivawin').css('border-left', 'solid 4px red');
		$('#selectiddivawin').css('border-right', 'solid 4px red');
		$('#selectiddivawin').css('border-bottom', 'solid 4px red');
	}
	else{
		$('#selectiddivawin').css('border-top', 'solid 0px red');
		$('#selectiddivawin').css('border-left', 'solid 0px red');
		$('#selectiddivawin').css('border-right', 'solid 0px red');
		$('#selectiddivawin').css('border-bottom', 'solid 0px red');
	}
}
function borderhighlightimg(id,flag) {
	if(flag=="true"){
		$('.selectiddivawin').css('border-top', 'solid 4px red');
		$('.selectiddivawin').css('border-left', 'solid 4px red');
		$('.selectiddivawin').css('border-right', 'solid 4px red');
		$('.selectiddivawin').css('border-bottom', 'solid 4px red');
	}
	else{
		$('.selectiddivawin').css('border-top', 'solid 0px red');
		$('.selectiddivawin').css('border-left', 'solid 0px red');
		$('.selectiddivawin').css('border-right', 'solid 0px red');
		$('.selectiddivawin').css('border-bottom', 'solid 0px red');
	}
}
